import {
  createRouter,
  createWebHistory,
  type RouteRecordRaw,
} from "vue-router";
import { ChatLayout } from "@/views/chat/layout";
import type { App } from "vue";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    name: "Root",
    component: ChatLayout,
    redirect: "/chat",
    children: [
      {
        path: "/chat/:uuid?",
        name: "Chat",
        component: () => import("@/views/chat/index.vue"),
      },
    ],
  },
];

export const router = createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

/** 初始化路由 */
export function initRouter(app: App) {
  app.use(router);
}
